export const alignX = {
  left: (x) => x + 8,
  center: (x, cellWidth) => x + cellWidth / 2,
  right: (x, cellWidth) => x + cellWidth - 8,
};

export const formatColumnList = (columns, rectWidth) => {
  const list = [];
  const notWidthCount = columns.filter((item) => !item.width).length;
  const sumWidth = columns
    .filter((item) => item.width)
    .reduce((prev, cur) => prev + cur.width, 0);
  const avgWidth = Math.floor((rectWidth - sumWidth) / notWidthCount);
  columns.forEach((item) => {
    if (!item.width) {
      item.width = avgWidth;
    }
    list.push(item);
  });
  return list;
};
